package com.irun.ibuffet.utils;

import java.io.File;

/***
 * @author huangsm
 * @date 2012-9-1
 * @email huangsanm@gmail.com
 * @desc 文件处理
 */
public class FileUtils {

	/**
	 * 目录结构是否存在
	 * @param path
	 * @return
	 */
	public static boolean exists(String path){
		return new File(path).exists();
	}
	
	/**
	 * sd卡是否挂载
	 * @return
	 */
	public static boolean hasSDCard(){
		return android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED);
	}
	
	/**
	 * 创建文件路径
	 * @param path
	 * @return
	 */
	public static boolean mkdir(String path){
		if(!exists(path)){
			File f = new File(path);
			return f.mkdir();
		}
		return true;
	}
	
	/**
	 * 并同创建子目录
	 * @param path
	 * @return
	 */
	public static boolean mkdirs(String path){
		if(!exists(path)){
			File f = new File(path);
			return f.mkdirs();
		}
		return true;
	}
}
